import {GameManager} from "db://assets/scripts/game/GameManager";
import {EffectUtils} from "db://assets/scripts/utils/EffectUtils";

/**
 * 游戏速度代理
 */
export class GameSpeedProxy {
    /**
     * 代理对象
     */
    private proxy: GameManager;

    /**
     * 游戏速度
     */
    private gameSpeed: number = 1;

    constructor(proxy: GameManager) {
        this.proxy = proxy;
    }

    /**
     * 设置游戏速度
     *
     * @param speed 游戏速度
     */
    public setGameSpeed(speed: number) {
        this.gameSpeed = speed;

        EffectUtils.refreshEffectSpeed(this.proxy.node, this.gameSpeed);
        EffectUtils.refreshEffectSpeed(this.proxy.gamePlayerProxy.getPlayerNode(), this.gameSpeed);
        EffectUtils.refreshEffectSpeed(this.proxy.effectManagerNode, this.gameSpeed);
    };

    public getGameSpeed() {
        return this.gameSpeed;
    }
}